#  Makefile
#
#  Copyright (C) 2011  Peter Polacik <polacik.p@gmx.com>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.

NAME = alogd

V_MAJOR = 1
V_MINOR = 9
V_PATCH = 0

# TODO: Version 1.9.0 (unstable) will become 2.0.0 (stable)
VERSION ?= $(V_MAJOR).$(V_MINOR).$(V_PATCH)

# Directories
PREFIX ?= /usr/local

BINDIR = $(PREFIX)/bin
DOCDIR = $(PREFIX)/share/doc/$(NAME)
MANDIR = $(PREFIX)/share/man

# Build settings
CC ?= gcc
CFLAGS += -c -std=gnu99 -Wall -Wextra -Wno-unused-value $(CDEBUG)
LDFLAGS += -Wall -Wextra -Wno-unused-value

OUTFILE ?= $(NAME)

OBJ = alogd.o usage.o config.o local.o logutil.o
# config.o - temporarily disabled

.PHONY: all

all: $(OUTFILE) $(OBJ)

$(OUTFILE): $(OBJ)
	$(CC) -o $@ $(LDFLAGS) $(OBJ)

libalogd/libalogd.so:
	make -f libalogd/Makefile all

.c.o:
	$(CC) $(CFLAGS) $<

debug:
#	make -f libalogd/Makefile CDEBUG="-DDEBUG -g"
	make CDEBUG="-DDEBUG -g" all

clean:
	rm -f *.o
	rm -f $(OUTFILE) debug.log
#	make -f libalogd/Makefile clean

# TODO: Add (un)installation routines
